﻿<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>{{title}}/{{entry}}</title>
</head>
<body>
    {{content|safe}}
    <script>
        //play sound
        player = document.createElement("audio")
        player.id = 'player'

        function play(url) {
            console.log(url)
            //var url = sound.href.replace("sound://", "")
            //var audio = document.createElement("audio")
            //player.pause()
            player.src = url
            player.play()
        }

        function makefunction(url)
        {
            return function (e) {
                play(url)
				e.preventDefault()
            }
        }
        var all_a = document.getElementsByTagName('a')
        for (i in all_a) {
            var item = all_a[i]
            if (item.href && item.href.lastIndexOf("sound://", 0) === 0) {
                var url = item.href.replace("sound://", "")
                var func = makefunction(url)
                item.addEventListener("click",
                    func
                )
            }

            if (item.href && item.href.lastIndexOf("entry://", 0) === 0) {
                item.href = item.href.replace("entry://", "")
            }
        }
    </script>
</body>

</html>